package com.jjty.dataGenerator.bg.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jjty.dataGenerator.bg.entity.SchoolInfo;
import com.jjty.dataGenerator.bg.mapper.SchoolMapper;
import com.jjty.dataGenerator.bg.service.SchoolService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author leikk
 * @since 2025-03-18
 */
@Service
public class SchoolServiceImpl extends ServiceImpl<SchoolMapper, SchoolInfo> implements SchoolService {

    @Autowired
    private SchoolMapper schoolMapper;

    @Override
    public Page getSchoolInfoPage(Page page, SchoolInfo param, String keyword) {
        page.setOptimizeCountSql(false);
        List<SchoolInfo> dictData = schoolMapper.getSchoolInfoPage(page,param,keyword);
        return page.setRecords(dictData);
    }

    @Override
    public boolean isEcidExists(String ecid) {
        return baseMapper.selectCount(new QueryWrapper<SchoolInfo>().eq("ecid", ecid)) > 0;
    }
}
